﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;
using System.Xml.Serialization;
using zEngine;
using zEngine.GameObjs;
using zEngine.Cameras;
using FYP.Profilings;

namespace FYP.TestCases
{
    public class TestCase2 : TestCase1
    {
        private zRender _renderer;

        #region Properties
        public zRender Renderer
        {
            get { return _renderer; }
            set { _renderer = value; }
        }
        #endregion
        
        /// <summary>
        /// Initializes a new instance of the TestCase1 class.
        /// </summary>
        public TestCase2(Game game, SpriteBatch sb)
            : base(game, sb)
        {
            TestcaseName = "Brute Force rendering profile. Remove objects out of sight.";
            DataFileOutput = "Data\\TestCase2.xml";
        }

        public override void Initialize()
        {
            base.Initialize();

            Renderer = new zRender(Game);
            Renderer.Camera = MainCam;
        }

        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);

            Renderer.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {
            DataManager.Draw(gameTime);
            Renderer.Draw(gameTime);

            // Display statistic for on-screen profilling
            SpriteBatch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.SaveState);
            SpriteBatch.DrawString(DebugFont, this.TestcaseName, new Vector2(200, 20), Color.Yellow);
            SpriteBatch.DrawString(DebugFont, "No of characters : " +  ListObj.Count.ToString(), new Vector2(40, 50), Color.White);
            SpriteBatch.End();
        }

        // Add 1 more character in to our list objects
        public override zObject AddMoreCharacter()
        {
            zObject newobj = base.AddMoreCharacter();
            Renderer.AddObject(newobj);
            return newobj;
        }


    }
}
